<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>a标签会先执行事件，再进行跳转（默认行为）</title>
</head>

<body>
    <a href="https://www.baidu.com" id="myTag">百度一下，你就知道</a>
</body>
<script>
    var myTag = document.getElementById("myTag");
    myTag.onclick = function (e) {
        alert(33);
        this.href = "http://www.w3school.com.cn/b.asp";
    }
</script>

</html>